#___________________________________________________________________________________________________________________________________________
#___________________________________________________________________________________________________________________________________________
#___________________________________________________________________________________________________________________________________________
inherit CometDimitri_PM_P_U_basic PM_U_Container
#___________________________________________________________________________________________________________________________________________
method CometDimitri_PM_P_U_basic constructor {name descr args} {
 this inherited $name $descr
   this set_nb_max_mothers   1
   this set_GDD_id GDD_CometExpeEmeric_PM_P_U_basic
   
   this set_default_op_gdd_file    [Comet_files_root]Comets/CSS_STYLESHEETS/GDD/Common_GDD_requests.css++
   this set_default_css_style_file [Root_of_CometDimitri]CSS/basic.css++

 eval "$objName configure $args"
 return $objName
}

#___________________________________________________________________________________________________________________________________________
Methodes_set_LC CometDimitri_PM_P_U_basic [P_L_methodes_set_CometDimitri] {} {}
Methodes_get_LC CometDimitri_PM_P_U_basic [P_L_methodes_get_CometDimitri] {$this(FC)}

#___________________________________________________________________________________________________________________________________________
Generate_PM_setters CometDimitri_PM_P_U_basic [P_L_methodes_set_CometDimitri_COMET_RE]

#___________________________________________________________________________________________________________________________________________
#___________________________________________________________________________________________________________________________________________
#___________________________________________________________________________________________________________________________________________
method CometDimitri_PM_P_U_basic set_LM {LM} {
 set rep [this inherited $LM]
 
 set this(cont)               "${objName}_cont"
 set this(cont_for_daughters) "${objName}_cont_for_daughters"
 set this(cont_for_compo)     "${objName}_cont_daughters"
 set this(cont_tools)         "${objName}_cont_tools"
 set this(cont_commands)      "${objName}_cont_commands"
 if {![gmlObject info exists object $this(cont)]} {
   this set_L_nested_handle_LM    $this(cont)_LM_LP
   this set_L_nested_daughters_LM $this(cont_for_daughters)_LM_LP

   CometContainer $this(cont)               "PM root of [this get_name]" {} -Add_style_class "CONTAINER INTERNAL_ROOT ROOT root"
   set this(top_interleaving)               [CPool get_a_comet CometInterleaving -set_name "Top interleaving" -Add_style_class "INTERLEAVING TOP"]
     set this(cont_graph_preso)             [CPool get_a_comet CometContainer    -set_name "Graph of the observed COMET" -Add_style_class "CONT CONTAINER OBSERVED COMET"]
	 set this(comet_viewer)                 [CPool get_a_comet CometViewer       -set_name "Comet Viewer" -Add_style_class "COMET GRAPH VIEWER"]
	 set this(choice_version)               [CPool get_a_comet CometChoice       -set_name "Choice of the observed version" -set_nb_max_choices 100 -Add_style_class "CHOICE VERSION OBSERVED COMET"]
	 $this(cont_graph_preso) set_daughters_R [list $this(comet_viewer) $this(choice_version)]

	set this(cont_evol_network)              [CPool get_a_comet CometContainer    -set_name "Container of the Evolution Network" -Add_style_class "CONT CONTAINER EVOLUTION NETWORK"]
   CometContainer $this(cont_for_compo)     "Edition"                    {} -Add_style_class "EDITION CANVAS"
   CometContainer $this(cont_for_daughters) "Daughters"                  {} -Add_style_class "CONT OUT DAUGHTERS"
   CometContainer $this(cont_tools)         "Tools Box"                  {} -Add_style_class "CONT TOOL TOOLS BOX TOOLBOX TOOLSBOX"
   CometContainer $this(cont_commands)      "Commands Box"               {} -Add_style_class "CONT COMMANDS"
   
   $this(cont)              Add_daughters_R [list $this(top_interleaving)]
   $this(top_interleaving)  Add_daughters_R [list $this(cont_evol_network) $this(cont_graph_preso) $this(cont_for_daughters)]
   $this(cont_evol_network) Add_daughters_R [list $this(cont_commands) $this(cont_tools) $this(cont_for_compo)]
   
   $this(cont_for_compo) set_daughters_R [[this get_LC] get_cont_compo  ]
   $this(cont_tools)     set_daughters_R [[this get_LC] get_choice_class]
   
   $this(cont_commands) set_daughters_R [list [CPool get_a_comet CometActivator -set_text "Reset" -Add_style_class "ACTIVATOR COMMAND RESET"      -Subscribe_to_activate $objName "$objName prim_Reset"     U] \
                                              [CPool get_a_comet CometActivator -set_text "Play"  -Add_style_class "ACTIVATOR COMMAND PLAY PAUSE" -Subscribe_to_activate $objName "$objName prim_PlayPause" U] \
											  [CPool get_a_comet CometActivator -set_text "Step"  -Add_style_class "ACTIVATOR COMMAND STEP"       -Subscribe_to_activate $objName "$objName prim_Step"      U] \
											  [CPool get_a_comet CometActivator -set_text "Save"  -Add_style_class "ACTIVATOR COMMAND SAVE"       -Subscribe_to_activate $objName "$objName Save_network_in_file {}"      U] \
											  [CPool get_a_comet CometActivator -set_text "Load"  -Add_style_class "ACTIVATOR COMMAND LOAD"       -Subscribe_to_activate $objName "$objName Load_network_from_file {}"      U] \
                                        ]
   set this(reconnect_LM) 1
   
   # Bindings
   $this(comet_viewer) Subscribe_to_Enlight  $objName  "$objName Update_enlights \$L"
  }
  
 return $rep
}

#___________________________________________________________________________________________________________________________________________
Manage_CallbackList CometDimitri_PM_P_U_basic [list set_L_connexions Add_L_connexions Sub_L_connexions set_L_instance_compo Add_L_instance_compo Sub_L_instance_compo] begin

#___________________________________________________________________________________________________________________________________________
Inject_code CometDimitri_PM_P_U_basic PlayPause {} {
  foreach C [CSS++ $objName "#${objName}(COMMAND.PLAY.PAUSE->LC)"] {$C set_text [lindex [list Play Pause] [this get_state_play_pause]]}
}

#___________________________________________________________________________________________________________________________________________
Inject_code CometDimitri_PM_P_U_basic set_comet_root_to_be_transformed {} {
 $this(comet_viewer) set_element_and_level "$v 10"
} __Update_graph__

#___________________________________________________________________________________________________________________________________________
Inject_code CometDimitri_PM_P_U_basic Step {} {
 set L [$this(choice_version) get_out_daughters]; $this(choice_version) set_daughters_R [list]; $this(choice_version) set_currents [list]
 foreach e $L {$e dispose}
 this Add_to_L_choice_versions [CSS++ $objName "#${objName}(CANVAS PROCESSING->LC)"] 
} __Update_choices_version__

#___________________________________________________________________________________________________________________________________________
method CometDimitri_PM_P_U_basic Add_to_L_choice_versions {L_versions} {
 foreach v $L_versions {
   set i 1
   foreach e [CSS++ $objName "#${v}->PMs([this get_comet_root_to_be_transformed])"] {
     puts "  Add $e as version choice $this(choice_version)..."
	 set name "[$v get_name] : version $i"
     $this(choice_version) Add_choices [CPool get_a_comet CometText -set_text $name -set_name $name -Add_MetaData PM_VERSION $e]
	 incr i
    }
  }
}


#___________________________________________________________________________________________________________________________________________
method CometDimitri_PM_P_U_basic Update_enlights {L} {
 set L_versions [list]
 foreach e [$this(choice_version) get_currents] {
   lappend L_versions "# [[$e Val_MetaData PM_VERSION] get_mothers]"
  }
 
 set css_expr "("
 append css_expr [join $L_versions ", "] ")  ("  [join $L ", "]  ")"
 
 #puts "css_expr : $css_expr   ===>  [CSS++ $objName $css_expr]"
 
 [[this get_L_roots] get_LC] Enlight_with_CSS++ $css_expr
}

#___________________________________________________________________________________________________________________________________________
Inject_code CometDimitri_PM_P_U_basic Save_network_in_file {
	set f_name "test.miga"
} {}
